//
//  SCIAPManager.h
//  SCSoundCommunity
//
//  Created by  on 2023/3/28.
//  Copyright © 2023 scTeam. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <StoreKit/StoreKit.h>

NS_ASSUME_NONNULL_BEGIN

typedef NS_ENUM(NSInteger, IAPFiledCode) {
    /**
     *  苹果返回错误信息
     */
    IAP_FILEDCOED_APPLECODE = 0,
    
    /**
     *  用户禁止应用内付费购买
     */
    IAP_FILEDCOED_NORIGHT = 1,
    
    /**
     *  商品为空
     */
    IAP_FILEDCOED_EMPTYGOODS = 2,
    /**
     *  无法获取产品信息，请重试
     */
    IAP_FILEDCOED_CANNOTGETINFORMATION = 3,
    /**
     *  购买失败，请重试
     */
    IAP_FILEDCOED_BUYFILED = 4,
    /**
     *  用户取消交易
     */
    IAP_FILEDCOED_USERCANCEL = 5
    
};

@protocol IApRequestResultsDelegate <NSObject>

- (void)filedWithErrorCode:(NSInteger)errorCode andError:(nullable NSString *)error; //失败

//- (void)paySuccessWithTransactionId:(NSString *)transactionId payload:(NSString *)payload;

- (void)paySuccess;


@end

@interface SCIAPManager : NSObject

+ (SCIAPManager *)sharedManager;

@property (nonatomic, weak) id<IApRequestResultsDelegate> delegate;

@property (nonatomic,copy) NSString *code;

- (void)startManager;
/**
 结束工具
 */
- (void)stopManager;

/**
 请求商品列表
 */
- (void)requestProductWithId:(NSString *)productId orderNo:(NSString *)orderNo price:(NSNumber *)price;

@end

NS_ASSUME_NONNULL_END
